//
//  AuthenTopTypeMiniVM.swift
//  kxf
//  小微商户进件   顶部tab
//  Created by Mac on 2024/3/6.
//

import Foundation
import UIKit

class AuthenTopTypeMiniVM: UIView {
    
    let selfHeight = kFitWidth(44)
    
    var type = "merc"
    var typeChangeBlock:((String)->())?

    override init(frame:CGRect){
        super.init(frame: CGRect.init(x: 0, y: frame.origin.y, width: SCREEN_WIDHT, height: selfHeight))
        self.backgroundColor = .white
        self.isUserInteractionEnabled = true
        
        initUI()
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    lazy var merchantMsgVM : AUthenTopTypeButton = {
        let vm = AUthenTopTypeButton.init(frame: CGRect.init(x: 0, y: 0, width: SCREEN_WIDHT*0.5, height: kFitWidth(44)))
        vm.titleLabel.text = "商户信息"
        vm.setSelected(isSelect: true)
        vm.tapBlock = {()in
            self.legalMsgVm.setSelected(isSelect: false)
            if self.type == "legal"{
                self.type = "merc"
                self.typeChangeAction()
            }
        }
        return vm
    }()
    lazy var legalMsgVm : AUthenTopTypeButton = {
        let vm = AUthenTopTypeButton.init(frame: CGRect.init(x: SCREEN_WIDHT*0.5, y: 0, width: SCREEN_WIDHT*0.5, height: kFitWidth(44)))
        vm.titleLabel.text = "店主信息"
        vm.tapBlock = {()in
            self.merchantMsgVM.setSelected(isSelect: false)
            if self.type == "merc"{
                self.type = "legal"
                self.typeChangeAction()
            }
        }
        return vm
    }()
}

extension AuthenTopTypeMiniVM{
    @objc func typeChangeAction() {
        if self.typeChangeBlock != nil{
            self.typeChangeBlock!(self.type)
        }
    }
}
extension AuthenTopTypeMiniVM{
    func initUI() {
        addSubview(merchantMsgVM)
        addSubview(legalMsgVm)
    }
}
